<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - multi_array/base.hpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../index.html">directory</a> - <a href="index.html">multi_array</a> - base.hpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">2</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">100.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">2</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : // Copyright 2002 The Trustees of Indiana University.
<span class="lineNum">       2 </span>                : 
<span class="lineNum">       3 </span>                : // Use, modification and distribution is subject to the Boost Software 
<span class="lineNum">       4 </span>                : // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       5 </span>                : // http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       6 </span>                : 
<span class="lineNum">       7 </span>                : //  Boost.MultiArray Library
<span class="lineNum">       8 </span>                : //  Authors: Ronald Garcia
<span class="lineNum">       9 </span>                : //           Jeremy Siek
<span class="lineNum">      10 </span>                : //           Andrew Lumsdaine
<span class="lineNum">      11 </span>                : //  See http://www.boost.org/libs/multi_array for documentation.
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span>                : #ifndef BASE_RG071801_HPP
<span class="lineNum">      14 </span>                : #define BASE_RG071801_HPP
<span class="lineNum">      15 </span>                : 
<span class="lineNum">      16 </span>                : //
<span class="lineNum">      17 </span>                : // base.hpp - some implementation base classes for from which
<span class="lineNum">      18 </span>                : // functionality is acquired
<span class="lineNum">      19 </span>                : //
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span>                : #include &quot;boost/multi_array/extent_range.hpp&quot;
<span class="lineNum">      22 </span>                : #include &quot;boost/multi_array/extent_gen.hpp&quot;
<span class="lineNum">      23 </span>                : #include &quot;boost/multi_array/index_range.hpp&quot;
<span class="lineNum">      24 </span>                : #include &quot;boost/multi_array/index_gen.hpp&quot;
<span class="lineNum">      25 </span>                : #include &quot;boost/multi_array/storage_order.hpp&quot;
<span class="lineNum">      26 </span>                : #include &quot;boost/multi_array/types.hpp&quot;
<span class="lineNum">      27 </span>                : #include &quot;boost/config.hpp&quot;
<span class="lineNum">      28 </span>                : #include &quot;boost/multi_array/concept_checks.hpp&quot; //for ignore_unused_...
<span class="lineNum">      29 </span>                : #include &quot;boost/mpl/eval_if.hpp&quot;
<span class="lineNum">      30 </span>                : #include &quot;boost/mpl/if.hpp&quot;
<span class="lineNum">      31 </span>                : #include &quot;boost/mpl/size_t.hpp&quot;
<span class="lineNum">      32 </span>                : #include &quot;boost/mpl/aux_/msvc_eti_base.hpp&quot;
<span class="lineNum">      33 </span>                : #include &quot;boost/iterator/reverse_iterator.hpp&quot;
<span class="lineNum">      34 </span>                : #include &quot;boost/static_assert.hpp&quot;
<span class="lineNum">      35 </span>                : #include &quot;boost/type.hpp&quot;
<span class="lineNum">      36 </span>                : #include &quot;boost/assert.hpp&quot;
<span class="lineNum">      37 </span>                : #include &lt;cstddef&gt;
<span class="lineNum">      38 </span>                : #include &lt;memory&gt;
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span>                : namespace boost {
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span>                : /////////////////////////////////////////////////////////////////////////
<span class="lineNum">      43 </span>                : // class declarations
<span class="lineNum">      44 </span>                : /////////////////////////////////////////////////////////////////////////
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span>                : template&lt;typename T, std::size_t NumDims,
<span class="lineNum">      47 </span>                :   typename Allocator = std::allocator&lt;T&gt; &gt;
<span class="lineNum">      48 </span>                : class multi_array;
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span>                : // This is a public interface for use by end users!
<span class="lineNum">      51 </span>                : namespace multi_array_types {
<span class="lineNum">      52 </span>                :   typedef boost::detail::multi_array::size_type size_type;
<span class="lineNum">      53 </span>                :   typedef std::ptrdiff_t difference_type;
<span class="lineNum">      54 </span>                :   typedef boost::detail::multi_array::index index;
<span class="lineNum">      55 </span>                :   typedef detail::multi_array::index_range&lt;index,size_type&gt; index_range;
<span class="lineNum">      56 </span>                :   typedef detail::multi_array::extent_range&lt;index,size_type&gt; extent_range;
<span class="lineNum">      57 </span>                :   typedef detail::multi_array::index_gen&lt;0,0&gt; index_gen;
<span class="lineNum">      58 </span>                :   typedef detail::multi_array::extent_gen&lt;0&gt; extent_gen;
<span class="lineNum">      59 </span>                : }
<span class="lineNum">      60 </span>                : 
<span class="lineNum">      61 </span>                : 
<span class="lineNum">      62 </span>                : // boost::extents and boost::indices are now a part of the public
<span class="lineNum">      63 </span>                : // interface.  That way users don't necessarily have to create their 
<span class="lineNum">      64 </span>                : // own objects.  On the other hand, one may not want the overhead of 
<span class="lineNum">      65 </span>                : // object creation in small-memory environments.  Thus, the objects
<span class="lineNum">      66 </span>                : // can be left undefined by defining BOOST_MULTI_ARRAY_NO_GENERATORS 
<span class="lineNum">      67 </span>                : // before loading multi_array.hpp.
<span class="lineNum">      68 </span>                : #if !BOOST_MULTI_ARRAY_NO_GENERATORS
<span class="lineNum">      69 </span>                : namespace {
<span class="lineNum">      70 </span><span class="lineCov">              5 :   multi_array_types::extent_gen extents;</span>
<span class="lineNum">      71 </span><span class="lineCov">              5 :   multi_array_types::index_gen indices;</span>
<span class="lineNum">      72 </span>                : }
<span class="lineNum">      73 </span>                : #endif // BOOST_MULTI_ARRAY_NO_GENERATORS
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                : namespace detail {
<span class="lineNum">      76 </span>                : namespace multi_array {
<span class="lineNum">      77 </span>                : 
<span class="lineNum">      78 </span>                : template &lt;typename T, std::size_t NumDims&gt;
<span class="lineNum">      79 </span>                : class sub_array;
<span class="lineNum">      80 </span>                : 
<span class="lineNum">      81 </span>                : template &lt;typename T, std::size_t NumDims, typename TPtr = const T*&gt;
<span class="lineNum">      82 </span>                : class const_sub_array;
<span class="lineNum">      83 </span>                : 
<span class="lineNum">      84 </span>                : template &lt;typename T, typename TPtr, typename NumDims, typename Reference&gt;
<span class="lineNum">      85 </span>                : class array_iterator;
<span class="lineNum">      86 </span>                : 
<span class="lineNum">      87 </span>                : template &lt;typename T, std::size_t NumDims, typename TPtr = const T*&gt;
<span class="lineNum">      88 </span>                : class const_multi_array_view;
<span class="lineNum">      89 </span>                : 
<span class="lineNum">      90 </span>                : template &lt;typename T, std::size_t NumDims&gt;
<span class="lineNum">      91 </span>                : class multi_array_view;
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span>                : /////////////////////////////////////////////////////////////////////////
<span class="lineNum">      94 </span>                : // class interfaces
<span class="lineNum">      95 </span>                : /////////////////////////////////////////////////////////////////////////
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span>                : class multi_array_base {
<span class="lineNum">      98 </span>                : public:
<span class="lineNum">      99 </span>                :   typedef multi_array_types::size_type size_type;
<span class="lineNum">     100 </span>                :   typedef multi_array_types::difference_type difference_type;
<span class="lineNum">     101 </span>                :   typedef multi_array_types::index index;
<span class="lineNum">     102 </span>                :   typedef multi_array_types::index_range index_range;
<span class="lineNum">     103 </span>                :   typedef multi_array_types::extent_range extent_range;
<span class="lineNum">     104 </span>                :   typedef multi_array_types::index_gen index_gen;
<span class="lineNum">     105 </span>                :   typedef multi_array_types::extent_gen extent_gen;
<span class="lineNum">     106 </span>                : };
<span class="lineNum">     107 </span>                : 
<span class="lineNum">     108 </span>                : //
<span class="lineNum">     109 </span>                : // value_accessor_n
<span class="lineNum">     110 </span>                : //  contains the routines for accessing elements from
<span class="lineNum">     111 </span>                : //  N-dimensional views.
<span class="lineNum">     112 </span>                : //
<span class="lineNum">     113 </span>                : template&lt;typename T, std::size_t NumDims&gt;
<span class="lineNum">     114 </span>                : class value_accessor_n : public multi_array_base {
<span class="lineNum">     115 </span>                :   typedef multi_array_base super_type;
<span class="lineNum">     116 </span>                : public:
<span class="lineNum">     117 </span>                :   typedef typename super_type::index index;
<span class="lineNum">     118 </span>                : 
<span class="lineNum">     119 </span>                :   // 
<span class="lineNum">     120 </span>                :   // public typedefs used by classes that inherit from this base
<span class="lineNum">     121 </span>                :   //
<span class="lineNum">     122 </span>                :   typedef T element;
<span class="lineNum">     123 </span>                :   typedef boost::multi_array&lt;T,NumDims-1&gt; value_type;
<span class="lineNum">     124 </span>                :   typedef sub_array&lt;T,NumDims-1&gt; reference;
<span class="lineNum">     125 </span>                :   typedef const_sub_array&lt;T,NumDims-1&gt; const_reference;
<span class="lineNum">     126 </span>                : 
<span class="lineNum">     127 </span>                : protected:
<span class="lineNum">     128 </span>                :   // used by array operator[] and iterators to get reference types.
<span class="lineNum">     129 </span>                :   template &lt;typename Reference, typename TPtr&gt;
<span class="lineNum">     130 </span>                :   Reference access(boost::type&lt;Reference&gt;,index idx,TPtr base,
<span class="lineNum">     131 </span>                :                    const size_type* extents,
<span class="lineNum">     132 </span>                :                    const index* strides,
<span class="lineNum">     133 </span>                :                    const index* index_bases) const {
<span class="lineNum">     134 </span>                : 
<span class="lineNum">     135 </span>                :     BOOST_ASSERT(idx - index_bases[0] &gt;= 0);
<span class="lineNum">     136 </span>                :     BOOST_ASSERT(size_type(idx - index_bases[0]) &lt; extents[0]);
<span class="lineNum">     137 </span>                :     // return a sub_array&lt;T,NDims-1&gt; proxy object
<span class="lineNum">     138 </span>                :     TPtr newbase = base + idx * strides[0];
<span class="lineNum">     139 </span>                :     return Reference(newbase,extents+1,strides+1,index_bases+1);
<span class="lineNum">     140 </span>                : 
<span class="lineNum">     141 </span>                :   }
<span class="lineNum">     142 </span>                : 
<span class="lineNum">     143 </span>                :   value_accessor_n() { }
<span class="lineNum">     144 </span>                :   ~value_accessor_n() { }
<span class="lineNum">     145 </span>                : };
<span class="lineNum">     146 </span>                : 
<span class="lineNum">     147 </span>                : 
<span class="lineNum">     148 </span>                : 
<span class="lineNum">     149 </span>                : //
<span class="lineNum">     150 </span>                : // value_accessor_one
<span class="lineNum">     151 </span>                : //  contains the routines for accessing reference elements from
<span class="lineNum">     152 </span>                : //  1-dimensional views.
<span class="lineNum">     153 </span>                : //
<span class="lineNum">     154 </span>                : template&lt;typename T&gt;
<span class="lineNum">     155 </span>                : class value_accessor_one : public multi_array_base {
<span class="lineNum">     156 </span>                :   typedef multi_array_base super_type;
<span class="lineNum">     157 </span>                : public:
<span class="lineNum">     158 </span>                :   typedef typename super_type::index index;
<span class="lineNum">     159 </span>                :   //
<span class="lineNum">     160 </span>                :   // public typedefs for use by classes that inherit it.
<span class="lineNum">     161 </span>                :   //
<span class="lineNum">     162 </span>                :   typedef T element;
<span class="lineNum">     163 </span>                :   typedef T value_type;
<span class="lineNum">     164 </span>                :   typedef T&amp; reference;
<span class="lineNum">     165 </span>                :   typedef T const&amp; const_reference;
<span class="lineNum">     166 </span>                : 
<span class="lineNum">     167 </span>                : protected:
<span class="lineNum">     168 </span>                :   // used by array operator[] and iterators to get reference types.
<span class="lineNum">     169 </span>                :   template &lt;typename Reference, typename TPtr&gt;
<span class="lineNum">     170 </span>                :   Reference access(boost::type&lt;Reference&gt;,index idx,TPtr base,
<span class="lineNum">     171 </span>                :                    const size_type* extents,
<span class="lineNum">     172 </span>                :                    const index* strides,
<span class="lineNum">     173 </span>                :                    const index* index_bases) const {
<span class="lineNum">     174 </span>                : 
<span class="lineNum">     175 </span>                :     ignore_unused_variable_warning(index_bases);
<span class="lineNum">     176 </span>                :     ignore_unused_variable_warning(extents);
<span class="lineNum">     177 </span>                :     BOOST_ASSERT(idx - index_bases[0] &gt;= 0);
<span class="lineNum">     178 </span>                :     BOOST_ASSERT(size_type(idx - index_bases[0]) &lt; extents[0]);
<span class="lineNum">     179 </span>                :     return *(base + idx * strides[0]);
<span class="lineNum">     180 </span>                :   }
<span class="lineNum">     181 </span>                : 
<span class="lineNum">     182 </span>                :   value_accessor_one() { }
<span class="lineNum">     183 </span>                :   ~value_accessor_one() { }
<span class="lineNum">     184 </span>                : };
<span class="lineNum">     185 </span>                : 
<span class="lineNum">     186 </span>                : 
<span class="lineNum">     187 </span>                : /////////////////////////////////////////////////////////////////////////
<span class="lineNum">     188 </span>                : // choose value accessor begins
<span class="lineNum">     189 </span>                : //
<span class="lineNum">     190 </span>                : 
<span class="lineNum">     191 </span>                : template &lt;typename T, std::size_t NumDims&gt;
<span class="lineNum">     192 </span>                : struct choose_value_accessor_n {
<span class="lineNum">     193 </span>                :   typedef value_accessor_n&lt;T,NumDims&gt; type;
<span class="lineNum">     194 </span>                : };
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                : template &lt;typename T&gt;
<span class="lineNum">     197 </span>                : struct choose_value_accessor_one {
<span class="lineNum">     198 </span>                :   typedef value_accessor_one&lt;T&gt; type;
<span class="lineNum">     199 </span>                : };
<span class="lineNum">     200 </span>                : 
<span class="lineNum">     201 </span>                : template &lt;typename T, typename NumDims&gt;
<span class="lineNum">     202 </span>                : struct value_accessor_generator {
<span class="lineNum">     203 </span>                :     BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims::value);
<span class="lineNum">     204 </span>                :     
<span class="lineNum">     205 </span>                :   typedef typename
<span class="lineNum">     206 </span>                :   mpl::eval_if_c&lt;(dimensionality == 1),
<span class="lineNum">     207 </span>                :                   choose_value_accessor_one&lt;T&gt;,
<span class="lineNum">     208 </span>                :                   choose_value_accessor_n&lt;T,dimensionality&gt;
<span class="lineNum">     209 </span>                :   &gt;::type type;
<span class="lineNum">     210 </span>                : };
<span class="lineNum">     211 </span>                : 
<span class="lineNum">     212 </span>                : #if BOOST_WORKAROUND(BOOST_MSVC, &lt; 1300)
<span class="lineNum">     213 </span>                : 
<span class="lineNum">     214 </span>                : struct eti_value_accessor
<span class="lineNum">     215 </span>                : {
<span class="lineNum">     216 </span>                :   typedef int index;
<span class="lineNum">     217 </span>                :   typedef int size_type;
<span class="lineNum">     218 </span>                :   typedef int element;
<span class="lineNum">     219 </span>                :   typedef int index_range;
<span class="lineNum">     220 </span>                :   typedef int value_type;
<span class="lineNum">     221 </span>                :   typedef int reference;
<span class="lineNum">     222 </span>                :   typedef int const_reference;
<span class="lineNum">     223 </span>                : };
<span class="lineNum">     224 </span>                :     
<span class="lineNum">     225 </span>                : template &lt;&gt;
<span class="lineNum">     226 </span>                : struct value_accessor_generator&lt;int,int&gt;
<span class="lineNum">     227 </span>                : {
<span class="lineNum">     228 </span>                :   typedef eti_value_accessor type;
<span class="lineNum">     229 </span>                : };
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span>                : template &lt;class T, class NumDims&gt;
<span class="lineNum">     232 </span>                : struct associated_types
<span class="lineNum">     233 </span>                :   : mpl::aux::msvc_eti_base&lt;
<span class="lineNum">     234 </span>                :         typename value_accessor_generator&lt;T,NumDims&gt;::type
<span class="lineNum">     235 </span>                :     &gt;::type
<span class="lineNum">     236 </span>                : {};
<span class="lineNum">     237 </span>                : 
<span class="lineNum">     238 </span>                : template &lt;&gt;
<span class="lineNum">     239 </span>                : struct associated_types&lt;int,int&gt; : eti_value_accessor {};
<span class="lineNum">     240 </span>                : 
<span class="lineNum">     241 </span>                : #else
<span class="lineNum">     242 </span>                : 
<span class="lineNum">     243 </span>                : template &lt;class T, class NumDims&gt;
<span class="lineNum">     244 </span>                : struct associated_types
<span class="lineNum">     245 </span>                :   : value_accessor_generator&lt;T,NumDims&gt;::type
<span class="lineNum">     246 </span>                : {};
<span class="lineNum">     247 </span>                : 
<span class="lineNum">     248 </span>                : #endif
<span class="lineNum">     249 </span>                : 
<span class="lineNum">     250 </span>                : //
<span class="lineNum">     251 </span>                : // choose value accessor ends
<span class="lineNum">     252 </span>                : /////////////////////////////////////////////////////////////////////////
<span class="lineNum">     253 </span>                : 
<span class="lineNum">     254 </span>                : 
<span class="lineNum">     255 </span>                : 
<span class="lineNum">     256 </span>                : ////////////////////////////////////////////////////////////////////////
<span class="lineNum">     257 </span>                : // multi_array_base
<span class="lineNum">     258 </span>                : ////////////////////////////////////////////////////////////////////////
<span class="lineNum">     259 </span>                : template &lt;typename T, std::size_t NumDims&gt;
<span class="lineNum">     260 </span>                : class multi_array_impl_base
<span class="lineNum">     261 </span>                :   :
<span class="lineNum">     262 </span>                : #if BOOST_WORKAROUND(BOOST_MSVC, &lt; 1300)
<span class="lineNum">     263 </span>                :       public mpl::aux::msvc_eti_base&lt;
<span class="lineNum">     264 </span>                :           typename value_accessor_generator&lt;T,mpl::size_t&lt;NumDims&gt; &gt;::type
<span class="lineNum">     265 </span>                :        &gt;::type
<span class="lineNum">     266 </span>                : #else
<span class="lineNum">     267 </span>                :       public value_accessor_generator&lt;T,mpl::size_t&lt;NumDims&gt; &gt;::type
<span class="lineNum">     268 </span>                : #endif 
<span class="lineNum">     269 </span>                : {
<span class="lineNum">     270 </span>                :   typedef associated_types&lt;T,mpl::size_t&lt;NumDims&gt; &gt; types;
<span class="lineNum">     271 </span>                : public:
<span class="lineNum">     272 </span>                :   typedef typename types::index index;
<span class="lineNum">     273 </span>                :   typedef typename types::size_type size_type;
<span class="lineNum">     274 </span>                :   typedef typename types::element element;
<span class="lineNum">     275 </span>                :   typedef typename types::index_range index_range;
<span class="lineNum">     276 </span>                :   typedef typename types::value_type value_type;
<span class="lineNum">     277 </span>                :   typedef typename types::reference reference;
<span class="lineNum">     278 </span>                :   typedef typename types::const_reference const_reference;
<span class="lineNum">     279 </span>                : 
<span class="lineNum">     280 </span>                :   template &lt;std::size_t NDims&gt;
<span class="lineNum">     281 </span>                :   struct subarray {
<span class="lineNum">     282 </span>                :     typedef boost::detail::multi_array::sub_array&lt;T,NDims&gt; type;
<span class="lineNum">     283 </span>                :   };
<span class="lineNum">     284 </span>                : 
<span class="lineNum">     285 </span>                :   template &lt;std::size_t NDims&gt;
<span class="lineNum">     286 </span>                :   struct const_subarray {
<span class="lineNum">     287 </span>                :     typedef boost::detail::multi_array::const_sub_array&lt;T,NDims&gt; type;
<span class="lineNum">     288 </span>                :   };
<span class="lineNum">     289 </span>                : 
<span class="lineNum">     290 </span>                :   template &lt;std::size_t NDims&gt;
<span class="lineNum">     291 </span>                :   struct array_view {
<span class="lineNum">     292 </span>                :     typedef boost::detail::multi_array::multi_array_view&lt;T,NDims&gt; type;
<span class="lineNum">     293 </span>                :   };
<span class="lineNum">     294 </span>                : 
<span class="lineNum">     295 </span>                :   template &lt;std::size_t NDims&gt;
<span class="lineNum">     296 </span>                :   struct const_array_view {
<span class="lineNum">     297 </span>                :   public:
<span class="lineNum">     298 </span>                :     typedef boost::detail::multi_array::const_multi_array_view&lt;T,NDims&gt; type;
<span class="lineNum">     299 </span>                :   };
<span class="lineNum">     300 </span>                : 
<span class="lineNum">     301 </span>                :   //
<span class="lineNum">     302 </span>                :   // iterator support
<span class="lineNum">     303 </span>                :   //
<span class="lineNum">     304 </span>                :   typedef array_iterator&lt;T,T*,mpl::size_t&lt;NumDims&gt;,reference&gt; iterator;
<span class="lineNum">     305 </span>                :   typedef array_iterator&lt;T,T const*,mpl::size_t&lt;NumDims&gt;,const_reference&gt; const_iterator;
<span class="lineNum">     306 </span>                : 
<span class="lineNum">     307 </span>                :   typedef ::boost::reverse_iterator&lt;iterator&gt; reverse_iterator;
<span class="lineNum">     308 </span>                :   typedef ::boost::reverse_iterator&lt;const_iterator&gt; const_reverse_iterator;
<span class="lineNum">     309 </span>                : 
<span class="lineNum">     310 </span>                :   BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims);
<span class="lineNum">     311 </span>                : protected:
<span class="lineNum">     312 </span>                : 
<span class="lineNum">     313 </span>                :   multi_array_impl_base() { }
<span class="lineNum">     314 </span>                :   ~multi_array_impl_base() { }
<span class="lineNum">     315 </span>                : 
<span class="lineNum">     316 </span>                :   // Used by operator() in our array classes
<span class="lineNum">     317 </span>                :   template &lt;typename Reference, typename IndexList, typename TPtr&gt;
<span class="lineNum">     318 </span>                :   Reference access_element(boost::type&lt;Reference&gt;,
<span class="lineNum">     319 </span>                :                            const IndexList&amp; indices,
<span class="lineNum">     320 </span>                :                            TPtr base,
<span class="lineNum">     321 </span>                :                            const size_type* extents,
<span class="lineNum">     322 </span>                :                            const index* strides,
<span class="lineNum">     323 </span>                :                            const index* index_bases) const {
<span class="lineNum">     324 </span>                : 
<span class="lineNum">     325 </span>                :     ignore_unused_variable_warning(index_bases);
<span class="lineNum">     326 </span>                :     ignore_unused_variable_warning(extents);
<span class="lineNum">     327 </span>                : #if !defined(NDEBUG) &amp;&amp; !defined(BOOST_DISABLE_ASSERTS)
<span class="lineNum">     328 </span>                :     for (size_type i = 0; i != NumDims; ++i) {
<span class="lineNum">     329 </span>                :       BOOST_ASSERT(indices[i] - index_bases[i] &gt;= 0);
<span class="lineNum">     330 </span>                :       BOOST_ASSERT(size_type(indices[i] - index_bases[i]) &lt; extents[i]);
<span class="lineNum">     331 </span>                :     }
<span class="lineNum">     332 </span>                : #endif
<span class="lineNum">     333 </span>                : 
<span class="lineNum">     334 </span>                :     index offset = 0;
<span class="lineNum">     335 </span>                :     for (size_type n = 0; n != NumDims; ++n) 
<span class="lineNum">     336 </span>                :       offset += indices[n] * strides[n];
<span class="lineNum">     337 </span>                :     
<span class="lineNum">     338 </span>                :     return base[offset];
<span class="lineNum">     339 </span>                :   }
<span class="lineNum">     340 </span>                : 
<span class="lineNum">     341 </span>                :   template &lt;typename StrideList, typename ExtentList&gt;
<span class="lineNum">     342 </span>                :   void compute_strides(StrideList&amp; stride_list, ExtentList&amp; extent_list,
<span class="lineNum">     343 </span>                :                        const general_storage_order&lt;NumDims&gt;&amp; storage)
<span class="lineNum">     344 </span>                :   {
<span class="lineNum">     345 </span>                :     // invariant: stride = the stride for dimension n
<span class="lineNum">     346 </span>                :     index stride = 1;
<span class="lineNum">     347 </span>                :     for (size_type n = 0; n != NumDims; ++n) {
<span class="lineNum">     348 </span>                :       index stride_sign = +1;
<span class="lineNum">     349 </span>                :       
<span class="lineNum">     350 </span>                :       if (!storage.ascending(storage.ordering(n)))
<span class="lineNum">     351 </span>                :         stride_sign = -1;
<span class="lineNum">     352 </span>                :       
<span class="lineNum">     353 </span>                :       // The stride for this dimension is the product of the
<span class="lineNum">     354 </span>                :       // lengths of the ranks minor to it.
<span class="lineNum">     355 </span>                :       stride_list[storage.ordering(n)] = stride * stride_sign;
<span class="lineNum">     356 </span>                :       
<span class="lineNum">     357 </span>                :       stride *= extent_list[storage.ordering(n)];
<span class="lineNum">     358 </span>                :     } 
<span class="lineNum">     359 </span>                :   }
<span class="lineNum">     360 </span>                : 
<span class="lineNum">     361 </span>                :   // This calculates the offset to the array base pointer due to:
<span class="lineNum">     362 </span>                :   // 1. dimensions stored in descending order
<span class="lineNum">     363 </span>                :   // 2. non-zero dimension index bases
<span class="lineNum">     364 </span>                :   template &lt;typename StrideList, typename ExtentList, typename BaseList&gt;
<span class="lineNum">     365 </span>                :   index
<span class="lineNum">     366 </span>                :   calculate_origin_offset(const StrideList&amp; stride_list,
<span class="lineNum">     367 </span>                :                           const ExtentList&amp; extent_list,
<span class="lineNum">     368 </span>                :                           const general_storage_order&lt;NumDims&gt;&amp; storage,
<span class="lineNum">     369 </span>                :                           const BaseList&amp; index_base_list)
<span class="lineNum">     370 </span>                :   {
<span class="lineNum">     371 </span>                :     return
<span class="lineNum">     372 </span>                :       calculate_descending_dimension_offset(stride_list,extent_list,
<span class="lineNum">     373 </span>                :                                             storage) +
<span class="lineNum">     374 </span>                :       calculate_indexing_offset(stride_list,index_base_list);
<span class="lineNum">     375 </span>                :   }
<span class="lineNum">     376 </span>                : 
<span class="lineNum">     377 </span>                :   // This calculates the offset added to the base pointer that are
<span class="lineNum">     378 </span>                :   // caused by descending dimensions
<span class="lineNum">     379 </span>                :   template &lt;typename StrideList, typename ExtentList&gt;
<span class="lineNum">     380 </span>                :   index
<span class="lineNum">     381 </span>                :   calculate_descending_dimension_offset(const StrideList&amp; stride_list,
<span class="lineNum">     382 </span>                :                                 const ExtentList&amp; extent_list,
<span class="lineNum">     383 </span>                :                                 const general_storage_order&lt;NumDims&gt;&amp; storage)
<span class="lineNum">     384 </span>                :   {
<span class="lineNum">     385 </span>                :     index offset = 0;
<span class="lineNum">     386 </span>                :     if (!storage.all_dims_ascending()) 
<span class="lineNum">     387 </span>                :       for (size_type n = 0; n != NumDims; ++n)
<span class="lineNum">     388 </span>                :         if (!storage.ascending(n))
<span class="lineNum">     389 </span>                :           offset -= (extent_list[n] - 1) * stride_list[n];
<span class="lineNum">     390 </span>                : 
<span class="lineNum">     391 </span>                :     return offset;
<span class="lineNum">     392 </span>                :   }
<span class="lineNum">     393 </span>                : 
<span class="lineNum">     394 </span>                :   // This is used to reindex array_views, which are no longer
<span class="lineNum">     395 </span>                :   // concerned about storage order (specifically, whether dimensions
<span class="lineNum">     396 </span>                :   // are ascending or descending) since the viewed array handled it.
<span class="lineNum">     397 </span>                : 
<span class="lineNum">     398 </span>                :   template &lt;typename StrideList, typename BaseList&gt;
<span class="lineNum">     399 </span>                :   index
<span class="lineNum">     400 </span>                :   calculate_indexing_offset(const StrideList&amp; stride_list,
<span class="lineNum">     401 </span>                :                           const BaseList&amp; index_base_list)
<span class="lineNum">     402 </span>                :   {
<span class="lineNum">     403 </span>                :     index offset = 0;
<span class="lineNum">     404 </span>                :     for (size_type n = 0; n != NumDims; ++n)
<span class="lineNum">     405 </span>                :         offset -= stride_list[n] * index_base_list[n];
<span class="lineNum">     406 </span>                :     return offset;
<span class="lineNum">     407 </span>                :   }
<span class="lineNum">     408 </span>                : 
<span class="lineNum">     409 </span>                :   // Slicing using an index_gen.
<span class="lineNum">     410 </span>                :   // Note that populating an index_gen creates a type that encodes
<span class="lineNum">     411 </span>                :   // both the number of dimensions in the current Array (NumDims), and 
<span class="lineNum">     412 </span>                :   // the Number of dimensions for the resulting view.  This allows the 
<span class="lineNum">     413 </span>                :   // compiler to fail if the dimensions aren't completely accounted
<span class="lineNum">     414 </span>                :   // for.  For reasons unbeknownst to me, a BOOST_STATIC_ASSERT
<span class="lineNum">     415 </span>                :   // within the member function template does not work. I should add a 
<span class="lineNum">     416 </span>                :   // note to the documentation specifying that you get a damn ugly
<span class="lineNum">     417 </span>                :   // error message if you screw up in your slicing code.
<span class="lineNum">     418 </span>                :   template &lt;typename ArrayRef, int NDims, typename TPtr&gt;
<span class="lineNum">     419 </span>                :   ArrayRef
<span class="lineNum">     420 </span>                :   generate_array_view(boost::type&lt;ArrayRef&gt;,
<span class="lineNum">     421 </span>                :                       const boost::detail::multi_array::
<span class="lineNum">     422 </span>                :                       index_gen&lt;NumDims,NDims&gt;&amp; indices,
<span class="lineNum">     423 </span>                :                       const size_type* extents,
<span class="lineNum">     424 </span>                :                       const index* strides,
<span class="lineNum">     425 </span>                :                       const index* index_bases,
<span class="lineNum">     426 </span>                :                       TPtr base) const {
<span class="lineNum">     427 </span>                : 
<span class="lineNum">     428 </span>                :     boost::array&lt;index,NDims&gt; new_strides;
<span class="lineNum">     429 </span>                :     boost::array&lt;index,NDims&gt; new_extents;
<span class="lineNum">     430 </span>                : 
<span class="lineNum">     431 </span>                :     index offset = 0;
<span class="lineNum">     432 </span>                :     size_type dim = 0;
<span class="lineNum">     433 </span>                :     for (size_type n = 0; n != NumDims; ++n) {
<span class="lineNum">     434 </span>                :       const index default_start = index_bases[n];
<span class="lineNum">     435 </span>                :       const index default_finish = default_start+extents[n];
<span class="lineNum">     436 </span>                :       const index_range&amp; current_range = indices.ranges_[n];
<span class="lineNum">     437 </span>                :       index start = current_range.get_start(default_start);
<span class="lineNum">     438 </span>                :       index finish = current_range.get_finish(default_finish);
<span class="lineNum">     439 </span>                :       index index_factor = current_range.stride();
<span class="lineNum">     440 </span>                : 
<span class="lineNum">     441 </span>                :       // integral trick for ceiling((finish-start) / index_factor)
<span class="lineNum">     442 </span>                :       index shrinkage = index_factor &gt; 0 ? 1 : -1;
<span class="lineNum">     443 </span>                :       index len = (finish - start + (index_factor - shrinkage)) / index_factor;
<span class="lineNum">     444 </span>                : 
<span class="lineNum">     445 </span>                :       BOOST_ASSERT(index_bases[n] &lt;= start &amp;&amp;
<span class="lineNum">     446 </span>                :                    start &lt;= index_bases[n]+index(extents[n]));
<span class="lineNum">     447 </span>                :       BOOST_ASSERT(index_bases[n] &lt;= finish &amp;&amp;
<span class="lineNum">     448 </span>                :                    finish &lt;= index_bases[n]+index(extents[n]));
<span class="lineNum">     449 </span>                :       BOOST_ASSERT(index_factor != 0);
<span class="lineNum">     450 </span>                : 
<span class="lineNum">     451 </span>                :       // the array data pointer is modified to account for non-zero
<span class="lineNum">     452 </span>                :       // bases during slicing (see [Garcia] for the math involved)
<span class="lineNum">     453 </span>                :       offset += start * strides[n];
<span class="lineNum">     454 </span>                : 
<span class="lineNum">     455 </span>                :       if (!current_range.is_degenerate()) {
<span class="lineNum">     456 </span>                : 
<span class="lineNum">     457 </span>                :         // The index_factor for each dimension is included into the
<span class="lineNum">     458 </span>                :         // strides for the array_view (see [Garcia] for the math involved).
<span class="lineNum">     459 </span>                :         new_strides[dim] = index_factor * strides[n];
<span class="lineNum">     460 </span>                :         
<span class="lineNum">     461 </span>                :         // calculate new extents
<span class="lineNum">     462 </span>                :         new_extents[dim] = len;
<span class="lineNum">     463 </span>                :         ++dim;
<span class="lineNum">     464 </span>                :       }
<span class="lineNum">     465 </span>                :     }
<span class="lineNum">     466 </span>                :     BOOST_ASSERT(dim == NDims);
<span class="lineNum">     467 </span>                : 
<span class="lineNum">     468 </span>                :     return
<span class="lineNum">     469 </span>                :       ArrayRef(base+offset,
<span class="lineNum">     470 </span>                :                new_extents,
<span class="lineNum">     471 </span>                :                new_strides);
<span class="lineNum">     472 </span>                :   }
<span class="lineNum">     473 </span>                :                      
<span class="lineNum">     474 </span>                : 
<span class="lineNum">     475 </span>                : };
<span class="lineNum">     476 </span>                : 
<span class="lineNum">     477 </span>                : } // namespace multi_array
<span class="lineNum">     478 </span>                : } // namespace detail
<span class="lineNum">     479 </span>                : 
<span class="lineNum">     480 </span>                : } // namespace boost
<span class="lineNum">     481 </span>                : 
<span class="lineNum">     482 </span>                : #endif // BASE_RG071801_HPP
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
